-
Try to duplicate the display at level crossings. The LED on PORTA BIT 0 should be lit while the one on bit 1 should be off, and vice versa. To do this you will need to set both bits as outputs and reverse the state on each flash.
[Exercise 1.5] -
At the moment the mark space ratio of on and off is equal. By mark space ration I mean the time the light is on in relation to the time the light is off. Modify the program so that the LED pulses rather than flashes. (To do this you must change the values in the for loops)
[Exercise 1.6] -
We have written the delay as a for loop which is repeated twice in the program. See if you can rewrite the program so that we have a function called delay which we can call to make a delay of a particular size. Make the function accept a parameter which is the size of the delay we require. To complete this you will need to find out how to create functions, click here to find out more.
[Exercise 1.7] -
This is the final one. I want you to change the program so that the flashing speed changes as the program runs. To do this you will need to use another variable (perhaps called speed) which is used to control the size of the delay. Each time you flash the LED you change the value in speed so that the next flash is a different length. Be careful that you don't let the speed value get too small, or your LED will stop flashing and just glow! (For real style write a program which makes the flash speed up and slow down again - to do this you will need to keep track whether you are counting up or counting down and change the timer value appropriately. To complete this you will need to find out how to create and modify variables, click here to find out more
[Exercise 1.8]